package br.ufal.ic.fracao.agent.resolution.operation.exponentiation;

import java.io.IOException;

import org.jdom.JDOMException;

import br.ufal.ic.fracao.especialist.domain.Item;
import br.ufal.ic.fracao.especialist.inference.InferenceAlgorithm;

public class ExponentiationAdapter {
	
	public String getSolution(int n1, int d1, int n2, int d2) throws IOException, JDOMException{
		InferenceAlgorithm algorithm = new InferenceAlgorithm();
				        
        Item fato1 = new Item();
        fato1.setDescription("Exponentiation");
        fato1.setValue(String.valueOf(true));
        fato1.setCertaintyFactor(0.2);
        algorithm.addToMemoryWorking(fato1);
                
        Item conclusion1 = new Item("(n1)^(n2)", "true");
        String result1 = algorithm.doForwardChaining(conclusion1, false);
                
        if (result1.equalsIgnoreCase("(n1)^(n2)")) {
        	return String.valueOf((int)Math.pow(n1, n2));
        }
		return null;
	}
}
